package io.gitee.zicai.bus.sample.adaptor;

import io.gitee.zicai.bus.adaptor.BaseBusReceiveAdaptor;
import io.gitee.zicai.bus.sample.cmd.CmdReceiveData;
import io.gitee.zicai.bus.sample.cmd.ICmdReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * CmdReceiveAdaptor
 *
 * @author zicai
 * @since 2021-04-02
 */
@Component
public class CmdReceiveAdaptor extends BaseBusReceiveAdaptor<ICmdReceiver, CmdReceiveBus, CmdReceiveData> {

    @Autowired
    private ICmdReceiver cmdReceiver;

    /**
     * 厂商的指令接收服务
     *
     * @param brandName 厂商名称
     * @return IBusReceiver
     */
    @Override
    public ICmdReceiver getCmdReceiver(String brandName) {
        return cmdReceiver;
    }

    public void receive(CmdReceiveData receiveData) {
        bus.publish(CmdReceiveBus.of(receiveData));
    }
}
